#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include"process.h"
#define N  101
#define STYLE  '='
void process1()
{
	const char* label = "|/-\\";	

	char process[N];
	memset(process,0,sizeof(process));
	int cnt = 0;
	 int len = strlen(label);
	while(cnt<=100)
	{
	
		printf("[%-100s][%d%%][%c]\r",process,cnt,label[cnt%len]);
		fflush(stdout);	
		process[cnt]=STYLE;
		usleep(30000);
		cnt++;
		
	}
	printf("\n");
}
void process2(double cur,double total)
{
	if(cur>=total)
		cur =total;
	static const char* label="|/-\\";
	char process[N];
	memset(process,0,sizeof(process));
	double rate = cur/total*100;
	int len = strlen(label);
	int cnt = (int)rate;
	int i = 0;
	static int index = 0;
	for(;i<cnt;i++)
	process[i] = STYLE;
		
	printf("[%-100s][%.1lf%%][%c]\r",process,rate,label[index++]);
		
	index%= len;
	fflush(stdout);

	
	if(cur>=total)
	{
		printf("\n");
	}
}
